//
//  BankCardDetailVC.m
//  MRBang
//
//  Created by 铅笔 on 16/4/21.
//  Copyright © 2016年 杭州易网新科技. All rights reserved.
//

#import "BankCardDetailVC.h"

#define CELLHEIGHT 195*PROPORTION_WIDTH

@interface BankCardDetailVC ()<UITableViewDataSource,UITableViewDelegate,LCActionSheetDelegate>

@property (nonatomic,strong) UITableView *tableView_bankCardDetail;

@end

@implementation BankCardDetailVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"银行卡详情";
    self.view.backgroundColor = COLOR_EVERYVIEWBG;
    
    UIButton *button_rightChange = [UIButton buttonWithType:UIButtonTypeCustom];
    [button_rightChange setTitle:@"管理"  forState:UIControlStateNormal];
    [button_rightChange setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    button_rightChange.frame = CGRectMake(15, 0, 40, 30);
    [button_rightChange.titleLabel setFont:[UIFont systemFontOfSize:24*PROPORTION_WIDTH]];
    
    UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button_rightChange];
    self.navigationItem.rightBarButtonItem = menuButton;
    
    [button_rightChange addTarget:self action:@selector(administrationBankCardAction)
                 forControlEvents:UIControlEventTouchUpInside];

    [self initWithBankCardDetailVCSubviews];

}

#pragma mark --- 创建明细表
- (void) initWithBankCardDetailVCSubviews
{
    self.tableView_bankCardDetail = [[UITableView alloc] initWithFrame:CGRectMake(0,0, kScreenWidth,310)];
    [self.view addSubview:self.tableView_bankCardDetail];
    self.tableView_bankCardDetail.dataSource = self;
    self.tableView_bankCardDetail.delegate = self;
    self.tableView_bankCardDetail.showsVerticalScrollIndicator = NO;
    self.tableView_bankCardDetail.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView_bankCardDetail.scrollEnabled = NO;
    self.tableView_bankCardDetail.backgroundColor = COLOR_EVERYVIEWBG;
    
}

#pragma mark --- UITableViewDataSource
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
//    return 2;
    //暂时隐藏掉 银行网点
    return 1;
}

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellMyBankCardID = @"cellCardRecordID";
    
    UITableViewCell *cell_myBankCard = [tableView cellForRowAtIndexPath:indexPath];
    if (cell_myBankCard == nil) {
        cell_myBankCard = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellMyBankCardID];
    }
    
    UIView *view_line = [[UIView alloc] initWithFrame:CGRectMake(27*PROPORTION_WIDTH, CELLHEIGHT-1, kScreenWidth, 1.0)];
    [cell_myBankCard.contentView addSubview:view_line];
    view_line.backgroundColor = [BaseViewController colorWithHexString:@"#EEEFF1"];
    
    cell_myBankCard.selectionStyle = UITableViewCellSelectionStyleNone;
    
    
    UILabel *label_leftTitle = [[UILabel alloc] init];
    [cell_myBankCard addSubview:label_leftTitle];
    
    //右侧 文字
    UILabel *label_rightContent = [[UILabel alloc] init];
    [cell_myBankCard addSubview:label_rightContent];
    
    if (indexPath.row==0) {
        
        //        label_leftTitle.frame = CGRectMake(27*PROPORTION_WIDTH, 31*PROPORTION_WIDTH, 158*PROPORTION_WIDTH, 20);
        //        label_leftTitle.font = [UIFont systemFontOfSize:30*PROPORTION_WIDTH];
        //        label_leftTitle.textColor = [BaseViewController colorWithHexString:@"#666666"];
        //        label_leftTitle.text = @"银行网点";
        
        
        UIImageView *imageView_card = [[UIImageView alloc] initWithFrame:CGRectMake(21*PROPORTION_WIDTH, 0, 364*PROPORTION_WIDTH, 200*PROPORTION_WIDTH)];
        [cell_myBankCard.contentView addSubview:imageView_card];
        imageView_card.image = [UIImage imageNamed:@"card"];

        label_rightContent.frame = CGRectMake(67*PROPORTION_WIDTH, 126*PROPORTION_WIDTH, 306*PROPORTION_WIDTH, 24*PROPORTION_WIDTH);
        label_rightContent.font = [UIFont systemFontOfSize:30*PROPORTION_WIDTH];
        label_rightContent.textColor = [BaseViewController colorWithHexString:@"#010101"];
        label_rightContent.text = @"**** **** **** 1234";

    }
    
//    if (indexPath.row==1) {
//        
//        UIImageView *imageView_map = [[UIImageView alloc] initWithFrame:CGRectMake(21*PROPORTION_WIDTH, 45*PROPORTION_WIDTH, 36*PROPORTION_WIDTH, 50*PROPORTION_WIDTH)];
//        [cell_myBankCard.contentView addSubview:imageView_map];
//        imageView_map.image = [UIImage imageNamed:@"mappin"];
//        
//        UIImageView *imageView_name = [[UIImageView alloc] initWithFrame:CGRectMake(20*PROPORTION_WIDTH+imageView_map.right, 28*PROPORTION_WIDTH, 145*PROPORTION_WIDTH, 68*PROPORTION_WIDTH)];
//        [cell_myBankCard.contentView addSubview:imageView_name];
//        imageView_name.image = [UIImage imageNamed:@"bankshop"];
//     }
    
    return cell_myBankCard;
}

- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   
    
}

- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row==0) {
        return CELLHEIGHT;
    }
    else
    {
        return  130*PROPORTION_WIDTH;
    }
}

//管理银行卡 执行事件
- (void) administrationBankCardAction
{
      
    // 类方法
    LCActionSheet *sheet = [LCActionSheet sheetWithTitle:nil
                                            buttonTitles:@[@"删除"]
                                          redButtonIndex:-1
                                                delegate:self];
    
    [sheet show];

}

#pragma mark - LCActionSheet 代理方法

- (void)actionSheet:(LCActionSheet *)actionSheet didClickedButtonAtIndex:(NSInteger)buttonIndex {
    
    NSLog(@"> Clicked Index: %ld", (long)buttonIndex);
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

@end
